<template>
  <view class="demo-container">
    <!-- 基础用法 -->
    <view class="demo-block">
      <view class="demo-block__title">基础用法</view>
      <view class="demo-block__content">
        <fu-field
          v-model:value="value1"
          label="用户名"
          placeholder="请输入用户名"
        />
        <fu-field
          v-model:value="value2"
          label="密码"
          type="password"
          placeholder="请输入密码"
        />
      </view>
    </view>
    
    <!-- 自定义内容 -->
    <view class="demo-block">
      <view class="demo-block__title">自定义内容</view>
      <view class="demo-block__content">
        <fu-field label="头像">
          <template #right>
            <image 
              class="avatar"
              src="/static/logo.png"
              mode="aspectFill"
            />
          </template>
        </fu-field>
        <fu-field label="验证码">
          <template #right>
            <fu-button 
              size="small"
              type="primary"
              @click="onSendCode"
            >发送验证码</fu-button>
          </template>
        </fu-field>
      </view>
    </view>
    
    <!-- 禁用和只读 -->
    <view class="demo-block">
      <view class="demo-block__title">禁用和只读</view>
      <view class="demo-block__content">
        <fu-field
          v-model:value="value3"
          label="禁用"
          disabled
          placeholder="输入框已禁用"
        />
        <fu-field
          v-model:value="value4"
          label="只读"
          readonly
          placeholder="输入框只读"
        />
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      value1: '',
      value2: '',
      value3: '',
      value4: ''
    }
  },
  methods: {
    onSendCode() {
      uni.showToast({
        title: '验证码已发送',
        icon: 'none'
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.demo-container {
  padding: 20rpx;
}

.demo-block {
  margin-bottom: 30rpx;
  
  &__title {
    margin-bottom: 20rpx;
    font-size: var(--fu-font-size-lg);
    color: var(--fu-text-color);
  }
  
  &__content {
    background-color: #fff;
    border-radius: var(--fu-radius-base);
    overflow: hidden;
  }
}

.avatar {
  width: 80rpx;
  height: 80rpx;
  border-radius: var(--fu-radius-base);
}
</style> 